<template>
    <div>     
        <Spin v-if="!images.length" class="loading"></Spin>
        <Carousel class="swipe-container" autoplay loop autoplay-speed=5000  v-else>
        <CarouselItem v-for="(item,index) in images" :key="index">
            <a :href="item.linkUrl" class="swipe-link">
                <img :src="item.picUrl" alt="" class="swipe-img">
            </a>
        </CarouselItem>
    </Carousel>
    </div>
    
</template>
<script>
import {getPic} from '../../assets/api/carousel';

export default {
    name: 'HomeCarousel',
    data(){
        return {
            images:[]
        }
    },
    methods: {
        getslider(){
            getPic().then(data=>{
                this.images = data
            })
        }
    },
    created(){
        this.getslider()
    },
    components: {
       
    }
}
</script>
<style lang="scss" scoped>
    .swipe-container{
        height: 183px;

        
        .swipe-link,.swipe-img{
            display: block;
            width: 100%;
            height: 183px;
        }
    }
    .loading{
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%)
    }
</style>